package net.halflite.mzkr.form.home;

import java.io.Serializable;

import net.halflite.mzkr.entity.RegistedUser;
import net.halflite.mzkr.entity.UserProfile;

import org.apache.commons.lang.builder.ReflectionToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.seasar.framework.container.annotation.tiger.Component;
import org.seasar.framework.container.annotation.tiger.InstanceType;
import org.seasar.struts.annotation.Arg;
import org.seasar.struts.annotation.EmailType;
import org.seasar.struts.annotation.Mask;
import org.seasar.struts.annotation.Maxlength;
import org.seasar.struts.annotation.Msg;
import org.seasar.struts.annotation.Required;
import org.seasar.struts.annotation.Validwhen;

/** プロフィール登録用/修正用ActionForm */
@Component(instance = InstanceType.SESSION)
public class ProfileForm implements Serializable {

	private static final long serialVersionUID = 1L;

	/** ユーザーID */
	@Validwhen(test = "(*this* != 0)",
			msg = @Msg(key = "errors.required"),
			arg0 = @Arg(key = "ユーザー情報", resource = false),
			target="input,confirm")
    public long registedUserId;

	/** メールアドレス */
	@Required(arg0 = @Arg(key = "メールアドレス", resource = false),
			target="validate")
	@Maxlength(maxlength = RegistedUser.MAX_ADDRESS_LENGTH,
			arg0 = @Arg(key = "メールアドレス", resource = false),
			target="validate")
	@Mask(mask = "^\\S+$", msg = @Msg(key = "errors.include.space"),
			arg0 = @Arg(key = "入力したメールアドレス", resource = false),
			target="validate")
	@EmailType(arg0 = @Arg(key = "入力したメールアドレス", resource = false),
			target="validate")
	public String address;

	/** 一行プロフィール */
	@Maxlength(maxlength = UserProfile.MAX_SHORTPROFILE_LENGTH, 
			arg0 = @Arg(key = "一行プロフィール", resource = false),
			target="validate")
	public String shortProfile;

	/** プロフィール */
	@Maxlength(maxlength = UserProfile.MAX_SHORTPROFILE_LENGTH, 
			arg0 = @Arg(key = "プロフィール", resource = false),
			target="validate")
	public String profile;
	
	/** アソシエイトID */
	public String associateId;
		
	@Override
	public String toString() {
		return ReflectionToStringBuilder.toString(this, ToStringStyle.SHORT_PREFIX_STYLE);
	}
}
